<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class Refundorderlist extends MY_Controller
{

    public function index()
    {
        $this->load->library('c_refund_order_list');

        $sendData = array();
        $sendData['enterpriseId'] = $this->lg_user['enterpriseId'];
        $sendData['channelId'] = $this->lg_user['channelId'];
        $sendData['userType'] = $this->lg_user['type'];
        $sendData['uid'] = $this->lg_user['id'];
        $sendData['password'] = $this->lg_user['password'];

        //制造接口请求
        $url = $this->c_refund_order_list->set_call_items($sendData);
        $param = $this->c_refund_order_list->get_call_items();
        $rs = $this->restcurl->get($url, $param);

        if ($rs['ErrorCode'] == 0 && $rs['Success'] == 1) {
            $this->c_refund_order_list->set_back_items($rs['CallInfo']);
        }

        $this->data['Data'] = $this->c_refund_order_list->get_back_items();
        $this->render('refundorderlist/index', $this->data);
    }
    public function detail(){
        $this->load->library('C_refund_order_detail');

        $sendData = array();
        $sendData['enterpriseId'] = $this->lg_user['enterpriseId'];
        $sendData['channelId'] = $this->lg_user['channelId'];
        $sendData['userType'] = $this->lg_user['type'];
        $sendData['uid'] = $this->lg_user['id'];
        $sendData['password'] = $this->lg_user['password'];
        $sendData['refund_id'] = $this->input->get('refund_id');
        //制造接口请求
        $url = $this->c_refund_order_detail->set_call_items($sendData);
        $param = $this->c_refund_order_detail->get_call_items();
        $rs = $this->restcurl->get($url, $param);
        if ($rs && $rs['ErrorCode'] == 0 && $rs['Success'] == 1) {
            $this->c_refund_order_detail->set_back_items($rs['CallInfo']);
            foreach ($rs['CallInfo']['workflowList'] as $key => $v){
                $key ++;
                if ($key % 2 == 0){
                    $body_below[] = $v;
                }else{
                    $body_up[] = $v;
                }
            }
            $up['up'] = $body_up;
            $below['below'] = $body_below;
            $res = array_merge($rs['CallInfo'],$up);
            $info = array_merge($res,$below);
            $this->data['detail'] = $info;
        }
        $this->render('refundorderlist/detail', $this->data);
    }
}